{include file="common/header"/}
<div class="lemo-container">
    <div class="lemo-main">
        <div class="admin-main layui-anim layui-anim-upbit">
            <fieldset class="layui-elem-field layui-field-title">
                <legend>{$title}</legend>
            </fieldset>
            <form class="layui-form layui-form-pane" lay-filter="form">
                <div class="layui-form-item">
                    <label class="layui-form-label">所属权限组</label>
                    <div class="layui-input-inline">
                        <select name="group_id" lay-verify="required">
                            <option value="">请选择权限组</option>
                            {volist name="authGroup" id="vo"}
                            <option value="{$vo.id}" {if !empty($info) && $info.group_id==$vo.id} selected {/if} >{$vo.title}</option>
                            {/volist}
                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">代理业务</label>
                    <div class="layui-input-inline">
                        <select name="type" lay-verify="required">
                            <option value="">请选择代理业务</option>
                            <option value="12671" {if !empty($info) && $info.type==$vo.id} selected {/if} >视频彩铃</option>
                            <option value="11555" {if !empty($info) && $info.type==$vo.id} selected {/if} >任性选</option>
                        </select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">名称</label>
                    <div class="layui-input-inline">
                        <input type="text" name="name" lay-verify="required" placeholder="{:lang('pleaseEnter')}名称" class="layui-input"  {/if}>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">账号</label>
                    <div class="layui-input-inline">
                        <input type="text" name="username" lay-verify="required" placeholder="{:lang('pleaseEnter')}登录用户名" class="layui-input"  {if  $info && $info.id!==1}readonly="readonly"{/if}>
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        用户名在4到25个字符之间。
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">{:lang('password')}</label>
                    <div class="layui-input-inline">
                        <input type="password" name="password" placeholder="{:lang('pleaseEnter')}登录密码" autocomplete="true" {if !empty($info)} lay-verify="required"{/if} class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        密码必须大于6位，小于15位。
                    </div>
                </div>
                
                <div class="layui-form-item">
                    <label class="layui-form-label">{:lang('mobile')}</label>
                    <div class="layui-input-inline">
                        <input type="text" name="mobile" lay-verify="phone" value="" placeholder="{:lang('pleaseEnter')}手机号" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline" style="margin-bottom: 15px;">
                     <label class="layui-form-label">省份：</label>
                     <div class="layui-input-inline">
                      <select name="provice_id" id="proviceId" lay-filter="proviceFilter" lay-search="">
                       <option value="">请选择省份</option>
                            {volist name="provice" id="vo"}
                            <option value="{$vo.id}" {if !empty($info) && $info.provice_id==$vo.id} selected {/if} >{$vo.name}</option>
                            {/volist}
                      </select>
                     </div>
                    </div>
                    <div class="layui-inline" style="margin-bottom: 15px;">
                     <label class="layui-form-label" style="color: black">城市：</label>
                     <div class="layui-input-inline">
                      <select name="city_id" id="cityId" lay-filter="cityIdFilter" lay-search="">
                       <option value="">请选择城市</option>
                       {if !empty($info)}
                            {volist name="city" id="vo"}
                                <option value="{$vo.id}" {if !empty($info) && $info.city_id==$vo.id} selected {/if} >{$vo.name}</option>
                            {/volist}
                        {/if}
                      </select>
                     </div>
                    </div>
                    <div class="layui-inline layui-word-aux" style="margin-bottom: 15px;">
                     非城市代理可不填
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-inline">
                        <input type="hidden" name="id"  >
                        <button type="button" class="layui-btn" lay-submit="" lay-filter="submit">{:lang('submit')}</button>
                        <a data-href="{:url('adminList')}" class="layui-btn layui-btn-primary back">{:lang('back')}</a>
                    </div>
                </div>
            </form>
        </div>

    </div>
</div>

{include file="common/footer"/}
<script>
    layui.config({
        base: '/static/admin/js/',
        version: true
    }).extend({
        Admin: 'Admin',
    }).use(['form','Admin'], function () {
        var form = layui.form, layer = layui.layer,$= layui.jquery;
        var info = '';
        info = {:json_encode($info)};
        form.val("form", info);
        if(info){
            $('#addPic').attr('src',info.avatar);
        }

        function getCity(data) {
            var params={
                provice:data.value
            }
            //检查项目添加到下拉框中
            $.ajax({
                url: '{:url("getCity")}',
                dataType: 'json',
                data : JSON.stringify(params),
                contentType: "application/json",  
                type: 'post',
                success: function (data) {
                    $("#cityId").empty();//清空下拉框的值
                    $('#cityId').append('<option value="">请选择城市</option>');// 下拉菜单里添加元素
                    $.each(data.data, function (index, item) {
                        $('#cityId').append(new Option(item.name, item.id));// 下拉菜单里添加元素
                    });
                    layui.form.render("select");//重新渲染 固定写法
                }
            });
        };

        form.on('select(proviceFilter)', function(data){
            getCity(data);
        });
        form.render();
    });
</script>